home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #2 / Monster Media No. 2 (Monster Media)(1994).ISO / utils1 / 2m21src.zip / 2MFBOTHD.ASM < prev    next >
Assembly Source File  |  1994-05-31  |  6KB  |  150 lines

  1.  
  2. ;┌───────────────────────────────────────────────────────────────────┐
  3. ;│                                                                   │
  4. ;│     2MFBOTHD 2.1  -  (C) Mayo 1994  Ciriaco García de Celis.      │
  5. ;│                                                                   │
  6. ;│         FICHERO CON CODIGO ENSAMBLADOR LINKABLE CON 2MF.C         │
  7. ;│                                                                   │
  8. ;│        Con código del sector de arranque para discos HD/ED.       │
  9. ;│                                                                   │
  10. ;└───────────────────────────────────────────────────────────────────┘
  11.  
  12. _DATA          SEGMENT WORD PUBLIC 'DATA'
  13.                ASSUME  CS:_DATA, DS:_DATA
  14.  
  15.                PUBLIC  _BootHDPrg, _BootHDPrgLong
  16.  
  17. _BootHDPrg:    CLI
  18.                XOR   AX,AX
  19.                MOV   SS,AX
  20.                MOV   SP,7C00h          ; SS:SP inicializado
  21.                MOV   AX,07C0h
  22.                PUSH  AX
  23.                ADD   AX,20h
  24.                PUSH  AX
  25.                POP   ES
  26.                POP   DS
  27.                XOR   SI,SI
  28.                XOR   DI,DI
  29.                MOV   CX,100h
  30.                CLD
  31.                REP   MOVSW             ; auto-reubicar este código
  32.                MOV   BX,DS:[68]        ; constante de reubicación
  33.                LEA   AX,[BX+OFFSET boot_ini - OFFSET _BootHDPrg]
  34.                PUSH  ES
  35.                PUSH  AX
  36.                RETF                    ; saltar a boot_ini reubicado
  37.  
  38. boot_ini:      STI
  39.                MOV   SI,OFFSET boot_txt - OFFSET _BootHDPrg
  40.                CALL  print
  41.                MOV   BX,1Eh*4
  42.                LDS   SI,DWORD PTR SS:[BX]
  43.                PUSH  DS                ; *
  44.                PUSH  SI                ; **
  45.                XOR   DI,DI
  46.                MOV   SS:[BX],DI
  47.                MOV   SS:[BX+2],ES
  48.                MOV   CX,11
  49.                REP   MOVSB             ; copiar tabla base disco a RAM
  50.                PUSH  ES
  51.                POP   DS
  52.                MOV   AL,DS:[24]
  53.                MOV   [DI-7],AL         ; sectores/pista correctos
  54.                XOR   AX,AX
  55.                MOV   ES,AX
  56.                MOV   BX,7C00h          ; ES:BX = 0000:7C00
  57.                MOV   ES:[BX+1FEh],AX   ; boot aún no válido
  58.                MOV   AX,0201h          ; leer un sector
  59.                MOV   CX,DS:[22]
  60.                ADD   CX,2              ; el primer sector de la FAT2
  61.                XOR   DX,DX             ; cabezal 0 y unidad A:
  62.                CMP   CX,10             ; ¿disquete de alta densidad?
  63.                JB    skip_code         ; (botará del disco duro)
  64.                PUSH  CX
  65.                INT   13h               ; cargar sector real de boot
  66.                POP   CX
  67.                MOV   BX,SS:[413h]
  68.                SUB   BX,5
  69.                MOV   AX,64
  70.                MUL   BX
  71.                MOV   ES,AX
  72.                PUSH  BX                ; ***
  73.                XOR   BX,BX
  74.                MOV   AX,205h           ; leer 5 sectores
  75.                INC   CX                ; cilindro 0 y 2º sector FAT2
  76.                XOR   DX,DX             ; cabezal 0 y unidad A:
  77.                INT   13h
  78.                POP   BX                ; ***
  79. skip_code:     POP   SS:[1Eh*4]        ; **  restaurar INT 1Eh
  80.                POP   SS:[1Eh*4+2]      ; *
  81.                CMP   WORD PTR ES:[2558],0AA55h  ; ¿código válido?
  82.                JNE   err_boot          ; fallo al cargar 2M SuperBOOT
  83.                MOV   SS:[413h],BX      ; rebajar memoria libre
  84.                PUSH  ES                ; *
  85.                MOV   AH,8
  86.                MOV   BL,0
  87.                MOV   DL,0
  88.                INT   13h               ; ¿tipo de unidad A:?
  89.                MOV   AL,BL
  90.                MOV   AH,0
  91.                CMP   DL,2
  92.                JB    ins_sb
  93.                PUSH  AX
  94.                MOV   AH,8
  95.                MOV   BL,0
  96.                MOV   DL,1
  97.                INT   13h               ; ¿tipo de unidad B:?
  98.                POP   AX
  99.                MOV   AH,BL
  100. ins_sb:        POP   ES                ; *
  101.                MOV   ES:[2558],ES           ; segmento del CALL FAR
  102.                CALL  DWORD PTR ES:[2556]    ; instalar SuperBOOT
  103.                MOV   AX,201h           ; leer un sector
  104.                XOR   DX,DX             ; cabezal 0 y unidad A:
  105.                MOV   ES,DX
  106.                MOV   CX,1              ; el sector 1 del cilindro 0
  107.                MOV   BX,8000h          ; acceso de lectura sólo para
  108.                PUSH  AX                ; quitar error "disco cambiado"
  109.                INT   13h
  110.                POP   AX
  111.                MOV   BX,7C00h
  112.                PUSH  ES                ; apilar dirección 0:7C00h
  113.                PUSH  BX
  114.                CMP   WORD PTR ES:[BX+3],"M2"
  115.                JNE   exec_boot         ; el BOOT virtual no es 2M
  116. hd_boot:       MOV   DL,80h            ; primer disco duro
  117.                INT   13h               ; cargar tabla de particiones
  118. exec_boot:     CMP   WORD PTR ES:[7DFEh],0AA55h
  119.                JNE   intenta_hd?
  120.                XOR   DX,DX             ; conviene DX=0 para Microsoft
  121.                RETF                    ; ejecutar partición / BOOT
  122. intenta_hd?:   AND   DL,DL
  123.                JZ    hd_boot           ; BOOT no válido, probar HD
  124.  
  125. err_boot:      MOV   SI,OFFSET no_boot_txt - OFFSET _BootHDPrg
  126.                CALL  print
  127.                MOV   AH,0
  128.                INT   16h               ; esperar tecla
  129.                INT   19h               ; volver a arrancar
  130.  
  131. print:         ADD   SI,DS:[68]
  132. putchar:       CLD
  133.                LODSB
  134.                AND   AL,AL
  135.                JZ    retorno
  136.                MOV   AH,0Eh
  137.                MOV   BX,7
  138.                INT   10h               ; imprimir carácter
  139.                JMP   putchar
  140. retorno:       RET
  141.  
  142. boot_txt       DB    13,10,"2M SuperBOOT 2.1",13,10,0
  143. no_boot_txt    DB    13,10,"¡No botable!",13,10,0
  144.  
  145. _BootHDPrgLong DW    $-OFFSET _BootHDPrg
  146.  
  147. _DATA          ENDS
  148.  
  149.                END
  150.